home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / toswinsc.zoo / iconify.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-27  |  2.1 KB  |  109 lines

  1. /*
  2.  * Copyright 1992 Eric R. Smith. All rights reserved.
  3.  * Redistribution is permitted only if the distribution
  4.  * is not for profit, and only if all documentation
  5.  * (including, in particular, the file "copying")
  6.  * is included in the distribution in unmodified form.
  7.  * THIS PROGRAM COMES WITH ABSOLUTELY NO WARRANTY, NOT
  8.  * EVEN THE IMPLIED WARRANTIES OF MERCHANTIBILITY OR
  9.  * FITNESS FOR A PARTICULAR PURPOSE. USE AT YOUR OWN
  10.  * RISK.
  11.  */
  12. #include "xgem.h"
  13. #include "twdefs.h"
  14. #include "twproto.h"
  15.  
  16. #define IM_RESERVE    12345
  17. #define IM_RELEASE    12346
  18. #define AP_TERM        50
  19.  
  20. #define DEF_WIDTH 32
  21. #define DEF_HEIGHT 32
  22.  
  23. /* set up an iconify request */
  24.  
  25. static void
  26. make_iconrequest(slot)
  27.     int slot;
  28. {
  29.     static int mbuf[8];
  30.     int id = appl_find ("ICONMGR ");
  31.     int x;
  32.  
  33.     mbuf[0] = IM_RESERVE;
  34.     mbuf[1] = gl_apid;
  35.     mbuf[2] = 0;
  36.     mbuf[3] = 0;
  37.  
  38.     if (id < 0) {
  39.         id = gl_apid;    /* send the message to ourselves */
  40.         x = xdesk+slot*(DEF_WIDTH+4);
  41.         if (x + DEF_WIDTH > xdesk + wdesk)
  42.             x = xdesk;
  43.         mbuf[3] = slot;
  44.         mbuf[4] = x;
  45.         mbuf[5] = ydesk+ hdesk - (DEF_HEIGHT+4);
  46.         mbuf[6] = DEF_WIDTH; mbuf[7] = DEF_HEIGHT;
  47.     }
  48.  
  49.     appl_write (id, 16, mbuf);
  50. }
  51.  
  52. /* function called when the user asks us to iconify a window */
  53.  
  54. static WINDOW *iconlock;
  55. static int res_slot;
  56.  
  57. void
  58. iconify_topwin()
  59. {
  60.     iconify_win(gl_topwin);
  61. }
  62.  
  63. void
  64. iconify_win(w)
  65.     WINDOW *w;
  66. {
  67.     int slot;
  68.  
  69.     if (!w || (w->flags & WICONIFIED)) return;
  70.     if (iconlock) return;    /* another window is being iconified */
  71.     iconlock = w;
  72.     if (w->icon_slot >= 0)
  73.         slot = w->icon_slot;
  74.     else
  75.         slot = res_slot++;
  76.     make_iconrequest(slot);
  77. }
  78.  
  79.  
  80. void
  81. iconify_message(msgbuff)
  82.     int *msgbuff;
  83. {
  84.     extern void quit();
  85.     WINDOW *w;
  86.  
  87.     switch(msgbuff[0]) {
  88.     case IM_RESERVE:
  89.         w = iconlock;
  90.         if (w) {
  91.             (*w->iconify)(w, msgbuff[3], msgbuff[4], msgbuff[5],
  92.                              msgbuff[6], msgbuff[7]);
  93.             iconlock = 0;
  94.         }
  95.         break;
  96.     case IM_RELEASE:
  97.         break;
  98.     case AP_TERM:
  99.         quit();
  100.         break;
  101.     case AC_OPEN:
  102.         ac_open();
  103.         break;
  104.     case AC_CLOSE:
  105.         force_ac_close();
  106.         break;
  107.     }
  108. }
  109.